<?xml version="1.0" encoding="iso-8859-1"?>

<!-- 
  -- Please see the readme.txt file included with this distribution for 
  -- attribution and copyright information.
  -->

<root version="2.0">
	<windowclass name="skillchallengetracker_rollitem">
		<sizelimits>
			<minimum>
				<height>25</height>
			</minimum>
		</sizelimits>
		<script>
			function onInit()
				registerMenuItem("Remove Roll", "deletepointer", 3);
			end

			function onMenuSelection(selection)
				if selection == 3 then
					getDatabaseNode().delete();
				end
			end
		</script>
		<sheetdata>
			<stringfield name="actor">
				<anchored>
					<left>
						<anchor>left</anchor>
						<offset>15</offset>
					</left>
					<top>
						<anchor>top</anchor>
						<offset>8</offset>
					</top>
					<size>
						<width>100</width>
					</size>
				</anchored>
				<font>chatfont</font>
				<static />
			</stringfield>

			<jpgnumberfield name="roll">
				<anchored>
					<left>
						<parent>actor</parent>
						<anchor>right</anchor>
						<offset>5</offset>
					</left>
					<top>
						<anchor>top</anchor>
						<offset>8</offset>
					</top>
					<size>
						<width>50</width>
					</size>
				</anchored>
				<font>chatfont</font>
				<static />
			</jpgnumberfield>
			<radiogroup name="result">
				<anchored>
					<to>roll</to>
					<position>right</position>
					<offset>40</offset>
				</anchored>
				<parameters>
					<optionwidth>70</optionwidth>
					<values>success|failure</values>
				</parameters>
			</radiogroup>
		</sheetdata>
	</windowclass>

	<windowclass name="skillchallengetracker_skilllistitem">
		<sizelimits>
			<minimum>
				<height>25</height>
			</minimum>
		</sizelimits>
		<script>
			local iscustom = true;
			
			function onInit()
				setRadialDeleteOption();

				results.getDatabaseNode().onChildAdded = onResultsChanged;
				results.getDatabaseNode().onChildUpdate = onResultsChanged;
				onResultsChanged();
			end
			
			function setCustom(flag)
				iscustom = flag;
				
				if not iscustom then
					label.setEnabled(false);
					label.setFrame(nil);
				end

				setRadialDeleteOption();
			end
			
			function setRadialDeleteOption()
				resetMenuItems();
				
				if iscustom then
					registerMenuItem("Delete Custom Skill", "delete", 6);
				end
			end
			
			function onMenuSelection(selection)
				if selection == 6 then
					getDatabaseNode().delete();
					SkillChallengeManager.calcTotals();
				end
			end
			
			function onResultsChanged()
				if (results.getDatabaseNode().getChildCount() > 0) then
					activate_results.setVisible(true);
				else
					activate_results.setVisible(false);
					activate_results.setValue(false);
				end
				
				SkillChallengeManager.calcTotals();
			end
		</script>
		<sheetdata>
			<stringfield name="label">
				<anchored>
					<left>
						<anchor>left</anchor>
						<offset>10</offset>
					</left>
					<top>
						<anchor>top</anchor>
						<offset>8</offset>
					</top>
					<size>
						<width>100</width>
					</size>
				</anchored>
				<font>sheetlabel</font>
				<frame>
					<name>textline</name>
					<offset>0,1,0,0</offset>
				</frame>
			</stringfield>

			<jpgnumberfield name="DC">
				<anchored>
					<left>
						<parent>label</parent>
						<anchor>right</anchor>
						<offset>20</offset>
					</left>
					<top>
						<anchor>top</anchor>
					</top>
					<size>
						<width>50</width>
						<height>25</height>
					</size>
				</anchored>
				<font>chatfont</font>
				<frame>
					<name>bonus</name>
					<offset>1,1,1,1</offset>
				</frame>
				<keyeditframe>
					<name>rowshade</name>
					<offset>2,2,2,2</offset>
				</keyeditframe>
				<stateframe>
					<drophilight>
						<name>sheetfocus</name>
						<offset>1,1,1,1</offset>
					</drophilight>
				</stateframe>
				<droptypes>
					<type>number</type>
				</droptypes>
				<hideonvalue>0</hideonvalue>
				<script>
					function onDrop(x, y, draginfo)
						if draginfo.getType() == "number" then
							setValue(draginfo.getNumberData());
						end

						return true;
					end
				</script>
			</jpgnumberfield>

			<jpgnumberfield name="success">
				<anchored>
					<left>
						<parent>DC</parent>
						<anchor>right</anchor>
						<offset>25</offset>
					</left>
					<top>
						<anchor>top</anchor>
					</top>
					<size>
						<width>50</width>
						<height>25</height>
					</size>
				</anchored>
				<font>chatfont</font>
				<frame>
					<name>modifier</name>
					<offset>1,1,1,1</offset>
				</frame>
				<hideonvalue>0</hideonvalue>
				<readonly />
				<script>
					function onDrop(x, y, draginfo)
						return false;
					end
				</script>
			</jpgnumberfield>
			<jpgnumberfield name="failure">
				<anchored>
					<left>
						<parent>success</parent>
						<anchor>right</anchor>
						<offset>18</offset>
					</left>
					<top>
						<anchor>top</anchor>
					</top>
					<size>
						<width>50</width>
						<height>25</height>
					</size>
				</anchored>
				<font>chatfont</font>
				<frame>
					<name>modifier</name>
					<offset>1,1,1,1</offset>
				</frame>
				<hideonvalue>0</hideonvalue>
				<readonly />
				<script>
					function onDrop(x, y, draginfo)
						return false;
					end
				</script>
			</jpgnumberfield>

			<button_toggle name="activate_results">
				<anchored>
					<left>
						<parent>failure</parent>
						<anchor>right</anchor>
						<offset>4</offset>
					</left>
					<bottom>
						<parent>failure</parent>
						<anchor>bottom</anchor>
						<offset>-4</offset>
					</bottom>
					<size>
						<width>10</width>
						<height>10</height>
					</size>
				</anchored>
				<icon>indicator_quicklist</icon>
				<script>
					function onValueChanged()
						window.results.setVisible(getValue());
					end
				</script>
			</button_toggle>

			<windowlist name="results">
				<anchored>
					<left>
						<parent>label</parent>
						<anchor>left</anchor>
					</left>
					<top>
						<parent>label</parent>
						<anchor>bottom</anchor>
					</top>
					<size>
						<width>350</width>
					</size>
				</anchored>
				<datasource>.rolls</datasource>
				<class>skillchallengetracker_rollitem</class>
				<invisible />
				<noscroll />
				<script>
					function altColor()
						local alt = true;

						for i, wnd in ipairs(getWindows()) do
							if alt then
								wnd.setFrame("rowshade",0,0,0,0);
							else
								wnd.setFrame(nil)
							end		
							alt = not alt;
						end
					end

					function onListRearranged(listchange)
						altColor();
					end
				</script>
			</windowlist>
		</sheetdata>
	</windowclass>

	<windowclass name="skillchallenge_tracker">
		<frame>sctbox</frame>
		<placement>
			<size>
				<width>400</width>
				<height>600</height>
			</size>
		</placement>
		<sizelimits>
			<minimum>
				<width>400</width>
				<height>600</height>
			</minimum>
			<maximum>
				<width>400</width>
				<height>600</height>
			</maximum>
		</sizelimits>
		<nodelete />
		<softclose />
		<sheetdata>
			<!-- TITLE -->
			<windowtitlebar>
				<title>
					<text>Skill Challenge Tracker</text>
				</title>
			</windowtitlebar>

			<!-- HEADERS -->
			<genericcontrol name="overviewframe">
				<bounds>20,60,-20,-80</bounds>				
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>

			<stringcontrol name="DClabel">
				<bounds>170,50,57,15</bounds>
				<font>sct-header</font>
				<static>DC</static>
			</stringcontrol>
			<stringcontrol name="successlabel">
				<anchored>
					<left>
						<parent>DClabel</parent>
						<anchor>right</anchor>
						<offset>6</offset>
					</left>
					<top>
						<parent>DClabel</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<width>50</width>
						<height>15</height>
					</size>
				</anchored>
				<font>sct-header</font>
				<static>Success</static>
			</stringcontrol>
			<stringcontrol name="failurelabel">
				<anchored>
					<left>
						<parent>successlabel</parent>
						<anchor>right</anchor>
						<offset>20</offset>
					</left>
					<top>
						<parent>DClabel</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<width>50</width>
						<height>15</height>
					</size>
				</anchored>
				<font>sct-header</font>
				<static>Failure</static>
			</stringcontrol>

			<!-- SKILL LIST -->
			<windowlist name="skilllist">
				<anchored>
					<to>overviewframe</to>
					<position>over</position>
					<offset>-5,-15</offset>
				</anchored>
				<datasource>.skills</datasource>
				<class>skillchallengetracker_skilllistitem</class>
				<script file="scripts/skillchallenge.lua" />
			</windowlist>
			<scrollercontrol>
				<anchored>
					<to>skilllist</to>
					<position>insidebottomright</position>
					<offset>0,-12</offset>
				</anchored>
				<target>skilllist</target>
				<button>
					<normal>button_scroller</normal>
					<pressed>button_scroller_down</pressed>
				</button>
			</scrollercontrol>

			<!-- TOTALS -->
			<genericcontrol name="totalframe">
				<anchored>
					<left>
						<parent>overviewframe</parent>
						<anchor>left</anchor>
					</left>
					<right>
						<parent>overviewframe</parent>
						<anchor>right</anchor>
					</right>
					<top>
						<parent>overviewframe</parent>
						<anchor>bottom</anchor>
					</top>
					<bottom>
						<anchor>bottom</anchor>
						<offset>-30</offset>
					</bottom>
				</anchored>
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>

			<stringcontrol name="totals">
				<anchored>
					<left>
						<anchor>left</anchor>
						<offset>160</offset>
					</left>
					<top>
						<parent>totalframe</parent>
						<anchor>top</anchor>
						<offset>20</offset>
					</top>
					<size>
						<width>50</width>
					</size>
				</anchored>
				<font>sheetlabel</font>
				<static>Totals:</static>
			</stringcontrol>

			<jpgnumberfield name="totalsuccess">
				<anchored>
					<left>
						<parent>totals</parent>
						<anchor>right</anchor>
						<offset>20</offset>
					</left>
					<top>
						<parent>totals</parent>
						<anchor>top</anchor>
						<offset>-6</offset>
					</top>
					<size>
						<width>50</width>
						<height>25</height>
					</size>
				</anchored>
				<font>chatfont</font>
				<frame>
					<name>modifier</name>
					<offset>1,1,1,1</offset>
				</frame>
				<readonly />
			</jpgnumberfield>
			<jpgnumberfield name="totalfailure">
				<anchored>
					<left>
						<parent>totalsuccess</parent>
						<anchor>right</anchor>
						<offset>18</offset>
					</left>
					<top>
						<parent>totals</parent>
						<anchor>top</anchor>
						<offset>-6</offset>
					</top>
					<size>
						<width>50</width>
						<height>25</height>
					</size>
				</anchored>
				<font>chatfont</font>
				<frame>
					<name>modifier</name>
					<offset>1,1,1,1</offset>
				</frame>
				<readonly />
			</jpgnumberfield>

			<buttoncontrol name="clear">
				<anchored>
					<left>
						<anchor>left</anchor>
						<offset>40</offset>
					</left>
					<top>
						<parent>totals</parent>
						<anchor>top</anchor>
						<offset>-6</offset>
					</top>
					<size>
						<width>33</width>
						<height>26</height>
					</size>
				</anchored>
				<icon>
					<normal>button_ctnextround</normal>
					<pressed>button_ctnextround_down</pressed>
				</icon>
				<tooltip>
					<text>Clear</text>
				</tooltip>
				<script>
					function onButtonPress()
						SkillChallengeManager.reset();
					end
				</script>
			</buttoncontrol>

			<closebutton_skillchallengetracker />
		</sheetdata>
	</windowclass>
</root>